sgdk: bmp.h Source File

sgdk

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

bmp.h
Go to the documentation of this file.

    00001
    00025 #ifndef _BMP_H_
    00026 #define _BMP_H_
    00027
    00028 #include "maths.h"
    00029 #include "vdp_pal.h"
    00030
    00031
    00036 #define BMP_PLAN                    APLAN
    00037 #define BMP_PLAN_ENUM               PLAN_A
    00038
    00039 #define BMP_PLANWIDTH_SFT           6
    00040 #define BMP_PLANHEIGHT_SFT          6
    00041
    00045 #define BMP_PLANWIDTH               (1 << BMP_PLANWIDTH_SFT)
    00046
    00050 #define BMP_PLANHEIGHT              (1 << BMP_PLANHEIGHT_SFT)
    00051
    00052 #define BMP_CELLWIDTH_SFT           5
    00053
    00057 #define BMP_CELLWIDTH               (1 << BMP_CELLWIDTH_SFT)
    00058
    00062 #define BMP_CELLHEIGHT              20
    00063 #define BMP_CELLWIDTHMASK           (BMP_CELLWIDTH - 1)
    00064
    00065 #define BMP_CELLXOFFSET             (((screenWidth >> 3) - BMP_CELLWIDTH) / 2)
    00066 #define BMP_CELLYOFFSET             (((screenHeight >> 3) - BMP_CELLHEIGHT) / 2)
    00067
    00068 #define BMP_XPIXPERTILE_SFT         3
    00069 #define BMP_YPIXPERTILE_SFT         3
    00070
    00074 #define BMP_XPIXPERTILE             (1 << BMP_XPIXPERTILE_SFT)
    00075
    00079 #define BMP_YPIXPERTILE             (1 << BMP_YPIXPERTILE_SFT)
    00080 #define BMP_XPIXPERTILEMASK         (BMP_XPIXPERTILE - 1)
    00081 #define BMP_YPIXPERTILEMASK         (BMP_YPIXPERTILE - 1)
    00082
    00083 #define BMP_WIDTH_SFT               (BMP_CELLWIDTH_SFT + BMP_XPIXPERTILE_SFT)
    00084
    00088 #define BMP_WIDTH                   (1 << BMP_WIDTH_SFT)
    00089
    00093 #define BMP_HEIGHT                  (BMP_CELLHEIGHT * BMP_YPIXPERTILE)
    00094 #define BMP_WIDTH_MASK              (BMP_WIDTH - 1)
    00095
    00096 #define BMP_PITCH_SFT               (BMP_CELLWIDTH_SFT + 2)
    00097
    00101 #define BMP_PITCH                   (1 << BMP_PITCH_SFT)
    00102 #define BMP_PITCH_MASK              (BMP_PITCH - 1)
    00103
    00108 #define BMP_GENBMP16_WIDTH(genbmp16)    ((genbmp16)[0])
    00109
    00113 #define BMP_GENBMP16_HEIGHT(genbmp16)   ((genbmp16)[1])
    00114
    00118 #define BMP_GENBMP16_PALETTE(genbmp16)  (&((genbmp16)[2]))
    00119
    00123 #define BMP_GENBMP16_IMAGE(genbmp16)    (&((genbmp16)[18]))
    00124
    00137 #define BMP_GETPIXEL(x, y)          bmp_buffer_write[((y) * BMP_PITCH) + ((x) >> 1)]
    00138
    00154 #define BMP_SETPIXEL(x, y, col)     bmp_buffer_write[((y) * BMP_PITCH) + ((x) >> 1)] = col;
    00155
    00156
    00157 #define BMP_BASETILEINDEX       TILE_USERINDEX
    00158
    00159 #define BMP_FB0TILEINDEX        BMP_BASETILEINDEX
    00160 #define BMP_FB1TILEINDEX        (BMP_BASETILEINDEX + (BMP_CELLWIDTH * BMP_CELLHEIGHT))
    00161
    00162 #define BMP_FB0ENDTILEINDEX     (BMP_FB0TILEINDEX + (BMP_CELLWIDTH * BMP_CELLHEIGHT))
    00163 #define BMP_FB1ENDTILEINDEX     (BMP_FB1TILEINDEX + (BMP_CELLWIDTH * BMP_CELLHEIGHT))
    00164
    00165 #define BMP_BASETILE            (BMP_BASETILEINDEX * 32)
    00166 #define BMP_FB0TILE             (BMP_FB0TILEINDEX * 32)
    00167 #define BMP_FB1TILE             (BMP_FB1TILEINDEX * 32)
    00168
    00169 #define BMP_FB0TILEMAP_BASE     BMP_PLAN
    00170 #define BMP_FB1TILEMAP_BASE     (BMP_PLAN + ((BMP_PLANWIDTH * (BMP_PLANHEIGHT / 2)) * 2))
    00171 #define BMP_FBTILEMAP_OFFSET    (((BMP_PLANWIDTH * BMP_CELLYOFFSET) + BMP_CELLXOFFSET) * 2)
    00172
    00173
    00192 typedef struct
    00193 {
    00194     u16 compression;
    00195     u16 w;
    00196     u16 h;
    00197     const Palette *palette;
    00198     const u8 *image;
    00199 } Bitmap;
    00200
    00209 typedef struct
    00210 {
    00211     Vect2D_s16 pt;
    00212     u8 col;
    00213 } Pixel;
    00214
    00225 typedef struct
    00226 {
    00227     Vect2D_s16 pt1;
    00228     Vect2D_s16 pt2;
    00229     u8 col;
    00230 } Line;
    00231
    00244 typedef struct
    00245 {
    00246     Vect2D_s16 pt1;
    00247     Vect2D_s16 pt2;
    00248     Vect2D_s16 pt3;
    00249     u8 col;
    00250 } Triangle;
    00251
    00252
    00256 extern u8 *bmp_buffer_read;
    00260 extern u8 *bmp_buffer_write;
    00261
    00262
    00281 void BMP_init(u16 double_buffer, u16 palette, u16 priority);
    00288 void BMP_end();
    00295 void BMP_reset();
    00296
    00321 u16 BMP_flip(u16 async);
    00322
    00327 void BMP_clear();
    00328
    00341 u8*  BMP_getWritePointer(u16 x, u16 y);
    00354 u8*  BMP_getReadPointer(u16 x, u16 y);
    00355
    00356
    00361 u16  BMP_hasFlipRequestPending();
    00366 void BMP_waitWhileFlipRequestPending();
    00371 u16  BMP_hasFlipInProgess();
    00377 void BMP_waitFlipComplete();
    00378
    00390 void BMP_drawText(const char *str, u16 x, u16 y);
    00402 void BMP_clearText(u16 x, u16 y, u16 w);
    00410 void BMP_clearTextLine(u16 y);
    00411
    00419 void BMP_showFPS(u16 float_display);
    00420
    00421
    00436 u8   BMP_getPixel(u16 x, u16 y);
    00453 void BMP_setPixel(u16 x, u16 y, u8 col);
    00468 void BMP_setPixels_V2D(const Vect2D_u16 *crd, u8 col, u16 num);
    00481 void BMP_setPixels(const Pixel *pixels, u16 num);
    00482
    00493 u8   BMP_clipLine(Line *l);
    00504 void BMP_drawLine(Line *l);
    00517 u16 BMP_isPolygonCulled(const Vect2D_s16 *pts, u16 num);
    00532 u16 BMP_drawPolygon(const Vect2D_s16 *pts, u16 num, u8 col);
    00533
    00554 void BMP_drawBitmapData(const u8 *data, u16 x, u16 y, u16 w, u16 h, u32 pitch);
    00577 u16 BMP_drawBitmap(const Bitmap *bitmap, u16 x, u16 y, u16 loadpal);
    00605 u16 BMP_drawBitmapScaled(const Bitmap *bitmap, u16 x, u16 y, u16 w, u16 h, u16 loadpal);
    00606
    00611 void BMP_loadBitmapData(const u8 *data, u16 x, u16 y, u16 w, u16 h, u32 pitch);
    00616 void BMP_loadBitmap(const Bitmap *bitmap, u16 x, u16 y, u16 loadpal);
    00621 void BMP_loadAndScaleBitmap(const Bitmap *bitmap, u16 x, u16 y, u16 w, u16 h, u16 loadpal);
    00622
    00627 void BMP_getBitmapPalette(const Bitmap *bitmap, u16 *pal);
    00628
    00653 void BMP_scale(const u8 *src_buf, u16 src_wb, u16 src_h, u16 src_pitch, u8 *dst_buf, u16 dst_wb, u16 dst_h, u16 dst_pitch);
    00654
    00655
    00656 #endif // _BMP_H_
    00657

All Classes Files Functions Variables Typedefs Enumerations Defines